package com.esri.core.geometry;

/* loaded from: classes.dex */
final class Envelope1D {
    public double vmax;
    public double vmin;

    public Envelope1D() {
    }

    public Envelope1D(double d, double d2) {
        setCoords(d, d2);
    }

    public void setCoords(double d, double d2) {
        this.vmin = d;
        this.vmax = d2;
    }

    public void setEmpty() {
        this.vmin = NumberUtils.NaN();
    }

    public boolean isEmpty() {
        return NumberUtils.isNaN(this.vmin);
    }

    public boolean isValid() {
        return (NumberUtils.isNaN(this.vmin) || NumberUtils.isNaN(this.vmax) || this.vmin > this.vmax) ? false : true;
    }

    public void setInfinite() {
        this.vmin = NumberUtils.negativeInf();
        this.vmax = NumberUtils.positiveInf();
    }

    public void merge(double d) {
        if (isEmpty()) {
            this.vmin = d;
            this.vmax = d;
            return;
        }
        mergeNE(d);
    }

    public void merge(Envelope1D envelope1D) {
        if (envelope1D.isEmpty()) {
            return;
        }
        if (isEmpty()) {
            this.vmin = envelope1D.vmin;
            this.vmax = envelope1D.vmax;
            return;
        }
        double d = this.vmin;
        double d2 = envelope1D.vmin;
        if (d > d2) {
            this.vmin = d2;
        }
        double d3 = this.vmax;
        double d4 = envelope1D.vmax;
        if (d3 < d4) {
            this.vmax = d4;
        }
        if (this.vmin > this.vmax) {
            setEmpty();
        }
    }

    public void mergeNE(double d) {
        if (d < this.vmin) {
            this.vmin = d;
        } else if (d > this.vmax) {
            this.vmax = d;
        }
    }

    public boolean contains(double d) {
        return d >= this.vmin && d <= this.vmax;
    }

    public void intersect(Envelope1D envelope1D) {
        if (isEmpty() || envelope1D.isEmpty()) {
            setEmpty();
            return;
        }
        double d = this.vmin;
        double d2 = envelope1D.vmin;
        if (d < d2) {
            this.vmin = d2;
        }
        double d3 = this.vmax;
        double d4 = envelope1D.vmax;
        if (d3 > d4) {
            this.vmax = d4;
        }
        if (this.vmin > this.vmax) {
            setEmpty();
        }
    }

    public void inflate(double d) {
        if (isEmpty()) {
            return;
        }
        double d2 = this.vmin - d;
        this.vmin = d2;
        double d3 = this.vmax + d;
        this.vmax = d3;
        if (d3 < d2) {
            setEmpty();
        }
    }

    double a() {
        double abs;
        if (isEmpty()) {
            abs = NumberUtils.doubleEps();
        } else {
            abs = (Math.abs(this.vmin) + Math.abs(this.vmax) + 1.0d) * NumberUtils.doubleEps();
        }
        return abs * 100.0d;
    }
}
